package test.circleimport.improve;

import java.math.BigDecimal;

public class Bill {
    private DiscountCalculator discountCal;
    private BigDecimal price;

    public Bill(DiscountCalculator discountCal, BigDecimal price) {
        this.discountCal = discountCal;
        this.price = price;
    }

    public BigDecimal pay() {
        BigDecimal discount = new BigDecimal(1)
                .subtract(this.discountCal.getDiscountAmount())
                .setScale(2, BigDecimal.ROUND_HALF_UP);
        return new BigDecimal(price.floatValue() * discount.floatValue());
    }

}
